using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ProtoBuf;

namespace Paradogs2.api
{
    public class NetMgr {
            /** ===================== ShopHandler ===================== */
        public class ShopHandler
        {
                public static async Task<Ack> buy(int cfgId, int count)
                {
                    var cg = new CGShopBuy();
                        cg.cfgId = cfgId;
                        cg.count = count;
                    return await WSGameServerConnection.Request<Ack>("shop.buy", cg);
                }

        }

        /** ===================== ConsumableHandler ===================== */
        public class ConsumableHandler
        {
        }

        /** ===================== FriendHandler ===================== */
        public class FriendHandler
        {
                public static async Task<Ack> apply(long val)
                {
                    var cg = new LongWrapper();
                        cg.val = val;
                    return await WSGameServerConnection.Request<Ack>("friend.apply", cg);
                }

                public static async Task<Ack> agree(long val)
                {
                    var cg = new LongWrapper();
                        cg.val = val;
                    return await WSGameServerConnection.Request<Ack>("friend.agree", cg);
                }

                public static async Task<Ack> refuse(long val)
                {
                    var cg = new LongWrapper();
                        cg.val = val;
                    return await WSGameServerConnection.Request<Ack>("friend.refuse", cg);
                }

        }

        /** ===================== AttrHandler ===================== */
        public class AttrHandler
        {
        }

        /** ===================== EquipHandler ===================== */
        public class EquipHandler
        {
                public static async Task<Ack> wear(long val)
                {
                    var cg = new LongWrapper();
                        cg.val = val;
                    return await WSGameServerConnection.Request<Ack>("equip.wear", cg);
                }

        }

        /** ===================== GMHandler ===================== */
        public class GMHandler
        {
                public static void addItem(int itemId, int count)
                {
                    var cg = new CGAddItem();
                        cg.itemId = itemId;
                        cg.count = count;
                    WSGameServerConnection.Send("gm.addItem", cg);
                }

        }

        /** ===================== MaterialHandler ===================== */
        public class MaterialHandler
        {
        }

        /** ===================== TaskHandler ===================== */
        public class TaskHandler
        {
        }

        /** ===================== InventoryHandler ===================== */
        public class InventoryHandler
        {
        }

        /** ===================== RoleHandler ===================== */
        public class RoleHandler
        {
                public static async Task<GCRoleDetails> details(long val)
                {
                    var cg = new LongWrapper();
                        cg.val = val;
                    return await WSGameServerConnection.Request<GCRoleDetails>("role.details", cg);
                }

                public static void logout()
                {
                    WSGameServerConnection.Send("role.logout", null);
                }

                public static async Task<Ack> login(string token)
                {
                    var cg = new CGLogin();
                        cg.token = token;
                    return await WSGameServerConnection.Request<Ack>("role.login", cg);
                }

        }

    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class Role : BaseEntity
    {
        [ProtoMember(4)]
        public int? level;
        [ProtoMember(5)]
        public long? exp;
        [ProtoMember(6)]
        public int? tired;
        [ProtoMember(7)]
        public string mood;
        [ProtoMember(8)]
        public string nickName;
        [ProtoMember(9)]
        public int? sex;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class ShopRecord : BaseMultiEntity
    {
        [ProtoMember(5)]
        public int? cfgId;
        [ProtoMember(6)]
        public int? buyCount;
        [ProtoMember(7)]
        public DateTime lastBuyTime;
    }


    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class EquipBase : BaseEntity
    {
        [ProtoMember(4)]
        public EquipWrap weapon;
        [ProtoMember(5)]
        public EquipWrap head;
        [ProtoMember(6)]
        public EquipWrap body;
        [ProtoMember(7)]
        public EquipWrap waist;
        [ProtoMember(8)]
        public EquipWrap glove;
        [ProtoMember(9)]
        public EquipWrap shoe;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class OwnerSyncData 
    {
        [ProtoMember(1)]
        public Role role;
        [ProtoMember(2)]
        public List<Material> materials;
        [ProtoMember(3)]
        public List<Consumable> consumables;
        [ProtoMember(4)]
        public List<Friend> friends;
        [ProtoMember(5)]
        public List<FriendApply> friendApplys;
        [ProtoMember(6)]
        public EquipBase equipBase;
        [ProtoMember(7)]
        public List<Equip> equips;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class Consumable : BaseMultiEntity
    {
        [ProtoMember(5)]
        public int? itemId;
        [ProtoMember(6)]
        public int? count;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class BooleanWrapper 
    {
        [ProtoMember(1)]
        public bool? val;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class CGShopBuy 
    {
        [ProtoMember(1)]
        public int? cfgId;
        [ProtoMember(2)]
        public int? count;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class FriendApply : BaseMultiEntity
    {
        [ProtoMember(5)]
        public long? applyUid;
        [ProtoMember(6)]
        public string applyName;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class BaseMultiEntity 
    {
        [ProtoMember(1)]
        public long? uid;
        [ProtoMember(2)]
        public long? id;
        [ProtoMember(3)]
        public DateTime createTime;
        [ProtoMember(4)]
        public DateTime updateTime;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class CGAddItem 
    {
        [ProtoMember(1)]
        public int? itemId;
        [ProtoMember(2)]
        public int? count;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class KickData 
    {
        [ProtoMember(1)]
        public string kickType;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class Material : BaseMultiEntity
    {
        [ProtoMember(5)]
        public int? itemId;
        [ProtoMember(6)]
        public int? count;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class LongWrapper 
    {
        [ProtoMember(1)]
        public long? val;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class PRMessage 
    {
        [ProtoMember(1)]
        public MessageHeader header;
        [ProtoMember(2)]
        public byte[] data;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class EquipWrap 
    {
        [ProtoMember(1)]
        public Equip equip;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class DoubleWrapper 
    {
        [ProtoMember(1)]
        public double? val;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class IntegerWrapper 
    {
        [ProtoMember(1)]
        public int? val;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class Equip : BaseMultiEntity
    {
        [ProtoMember(5)]
        public int? itemId;
        [ProtoMember(6)]
        public int? attr1;
        [ProtoMember(7)]
        public int? attr2;
        [ProtoMember(8)]
        public int? jiaBao;
        [ProtoMember(9)]
        public int? xueLianLevel;
        [ProtoMember(10)]
        public int? qiangHua;
        [ProtoMember(11)]
        public bool? jueXing;
        [ProtoMember(12)]
        public int? fuMoProgress;
        [ProtoMember(13)]
        public int? skillCfgId;
        [ProtoMember(14)]
        public int? breakDown;
        [ProtoMember(15)]
        public int? failChengZhang;
        [ProtoMember(16)]
        public int? durability;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class MessageHeader 
    {
        [ProtoMember(1)]
        public long? id;
        [ProtoMember(2)]
        public string server;
        [ProtoMember(3)]
        public string route;
        [ProtoMember(4)]
        public long? replyId;
        [ProtoMember(5)]
        public string channelId;
        [ProtoMember(6)]
        public long? uid;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class Friend : BaseMultiEntity
    {
        [ProtoMember(5)]
        public long? friendId;
        [ProtoMember(6)]
        public string friendName;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class CGLogin 
    {
        [ProtoMember(1)]
        public string token;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class StringWrapper 
    {
        [ProtoMember(1)]
        public string val;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class Attr : BaseEntity
    {
        [ProtoMember(4)]
        public Dictionary<int?, int?> finalAttr;
        [ProtoMember(5)]
        public Dictionary<int?, int?> attrs;
        [ProtoMember(6)]
        public int? curHp;
        [ProtoMember(7)]
        public int? curMp;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class WorldSyncData 
    {
        [ProtoMember(1)]
        public long? id;
        [ProtoMember(2)]
        public string name;
        [ProtoMember(3)]
        public int? unitType;
        [ProtoMember(4)]
        public int? level;
        [ProtoMember(5)]
        public int? curHp;
        [ProtoMember(6)]
        public int? maxHp;
        [ProtoMember(7)]
        public int? curMp;
        [ProtoMember(8)]
        public int? maxMp;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class ByteMessage 
    {
        [ProtoMember(1)]
        public MessageHeader header;
        [ProtoMember(2)]
        public byte[] dataBytes;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class GCRoleDetails 
    {
        [ProtoMember(1)]
        public long? id;
        [ProtoMember(2)]
        public int? level;
        [ProtoMember(3)]
        public int? sex;
        [ProtoMember(4)]
        public int? sectType;
        [ProtoMember(5)]
        public int? sectPost;
        [ProtoMember(6)]
        public string cellId;
        [ProtoMember(7)]
        public string cellName;
        [ProtoMember(8)]
        public string nickName;
        [ProtoMember(9)]
        public bool? online;
    }

    // [ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
    [ProtoContract]
    public class BaseEntity 
    {
        [ProtoMember(1)]
        public long? uid;
        [ProtoMember(2)]
        public DateTime createTime;
        [ProtoMember(3)]
        public DateTime updateTime;
    }


}

